﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;

namespace Complaint.Helpers
{
    public class ViewModelWithStaticSortedList<T> : IViewModel<T>
    {
        #region Implementation of IViewModel<T>

        public T Instance { get; set; }

        public SelectList PickList { get; private set; }

        public string TextField { get; private set; }

        public string ValueField { get; private set; }

        #endregion

        public ViewModelWithStaticSortedList(T model, IEnumerable<string> list, string defaultValue)
        {
            Instance = model;
            var sortedList = new SortedList<string, string>(list.ToDictionary(s => s));
            TextField = "Key";
            ValueField = "Value";

            PickList = new SelectList(list, TextField, ValueField, defaultValue);
        }
    }
}
